package com.qjdchina.sku.front.web.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qjdchina.common.web.util.RestBody;
import com.qjdchina.commons.result.Result;
import com.qjdchina.sku.biz.HardcoverStandardManager;
import com.qjdchina.sku.model.Category;
import com.qjdchina.sku.model.HardcoverStandard;
import com.qjdchina.sku.service.enums.SkuResultCode;


@Controller
@RequestMapping(value = "hardcoverStandard")
public class HardcoverStandardController {

    @Autowired
    private HardcoverStandardManager hardcoverStandardManager;

    /**
     * 获取所有精装标准
     * shenpingfeng
     * 2017年1月3日
     * @param request
     * @return
     */
    @RequestMapping(value = "list",method = RequestMethod.GET)
    @ResponseBody
    public RestBody<List<HardcoverStandard>> list(HttpServletRequest request){
    	Result<List<HardcoverStandard>> result = hardcoverStandardManager.getAllHardcoverStandard();
    	
        return new RestBody<List<HardcoverStandard>>(SkuResultCode.SUCCESS,result.getDataModel());
    }
    /**
     * 获取品类
     * shenpingfeng
     * 2017年1月5日
     * @param hardcoverStandardId
     * @param request
     * @return
     */
    @RequestMapping(value = "getCategory",method = RequestMethod.GET)
    @ResponseBody
    public RestBody<List<Category>> getCategory(@RequestParam(value = "hardcoverStandardId",required = true) Integer hardcoverStandardId,HttpServletRequest request){
    	Result<List<Category>> result = hardcoverStandardManager.getCategoryByHardcoverStandardId(hardcoverStandardId);
    	
        return new RestBody<List<Category>>(SkuResultCode.SUCCESS,result.getDataModel());
    }
}
